package com.fas.system.controller;

import com.fas.common.core.controller.BaseController;
import com.fas.common.core.domain.AjaxResult;
import com.fas.common.utils.SecurityUtils;
import com.fas.system.service.IHomePageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 首页 Controller
 *
 * @date 2022-07-20
 */
@Api(tags = "首页")
@RestController
@RequestMapping("/system/homePage")
public class HomePageController extends BaseController {

    @Resource
    private IHomePageService homePageService;

    /**
     * 单位联网情况
     */
    @ApiOperation(value = "单位联网情况")
    @GetMapping("/getOverviewDeptNum")
    public AjaxResult getOverviewDeptNum(Integer cooperationCompanyId){
        Integer deptId = SecurityUtils.getDeptId().intValue();
        return AjaxResult.success(homePageService.getOverviewDeptNum(deptId,cooperationCompanyId));
    }
    /**
     * 首页最近报警列表统计图
     */
    @ApiOperation(value = "首页最近报警列表统计图")
    @GetMapping("/getLatest7daysAlarmLines")
    public AjaxResult getLatest7daysAlarmLines(Integer cooperationCompanyId){
        Integer deptId = SecurityUtils.getDeptId().intValue();
        return AjaxResult.success(homePageService.getLatest7daysAlarmLines(deptId,cooperationCompanyId));
    }
    /**
     * 首页获取设备状态数量
     */
    @ApiOperation(value = "首页获取设备状态数量")
    @GetMapping("/getDeviceStatusNum")
    public AjaxResult getDeviceStatusNum(Integer cooperationCompanyId){
        Integer deptId = SecurityUtils.getDeptId().intValue();
        return AjaxResult.success(homePageService.getDeviceStatusNum(deptId,cooperationCompanyId));
    }
    /**
     * 首页获取今日隐患数量
     */
    @ApiOperation(value = "首页获取今日隐患数量")
    @GetMapping("/getTodayYHOrderNumRate")
    public AjaxResult getTodayYHOrderNumRate(Integer cooperationCompanyId){
        Integer deptId = SecurityUtils.getDeptId().intValue();
        return AjaxResult.success(homePageService.getTodayYHOrderNumRate(deptId,cooperationCompanyId));
    }
}
